﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Collections;
using System.Data.OracleClient;

namespace Lyon.Data.ORM.DataBases
{
    /// <summary>
    /// Ole数据库。
    /// </summary>
    public class DataBaseForOracle : AbstractDataBase, IDataBase
    {
        //DATA SOURCE=localhost;USER ID=SYSTEM;PASSWORD=123456
        /// <summary>
        /// 连接字符格式
        /// </summary>
        public const string ConnFormat = "DATA SOURCE={0};USER ID={1};PASSWORD={2}";

        string _ConnectionString;

        /// <summary>
        /// 创建一个打开的数据库连接。
        /// </summary>
        protected override IDbConnection CreateConnection()
        {
            OracleConnection conn = new OracleConnection(_ConnectionString);
            return conn;
        }
        /// <summary>
        /// 参数名前缀。
        /// </summary>
        protected override string ParameterNamePrefix
        {
            get { return ":"; }
        }
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="dataSource">服务地址或名称</param>
        /// <param name="userID">用户名</param>
        /// <param name="password">密码</param>
        public DataBaseForOracle(string dataSource, string userID, string password)
        {
            Guard.ArgumentNotNullOrEmptyString(dataSource, "dataSource");
            Guard.ArgumentNotNullOrEmptyString(userID, "userID");
            Guard.ArgumentNotNullOrEmptyString(password, "password");
            _ConnectionString = String.Format(ConnFormat, dataSource, userID, password);
        }
    }
}
